<?php

if(isset($_POST['dev_id'])){
$dev_id = $_POST['dev_id'];
$test_series_desc = $_POST['test_series_desc'];
}else{
$dev_id = $_GET['dev_id'];
}

include 'db_connection.php';
include 'navigation.php';

if(isset($_POST['dev_id']) && !empty($_POST['dev_id'])){
$query4 = "insert into TEST_SERIES values($dev_id, '', '$test_series_desc')";
//execute query
$QueryResult4 = @mysqli_query($DBConnect, $query4) or die("<p>Unable to execute query4.</p>");	
}

$query = "select * from TEST_SERIES where Dev_id=$dev_id";
//execute query
$QueryResult = @mysqli_query($DBConnect, $query) or die("<p>Unable to execute query.</p>");	

$num_attributes = mysqli_num_fields($QueryResult);
$attributes = mysqli_fetch_fields($QueryResult);

echo "<h1>Test Series</h1>";

echo "<table border ='0'>";

  echo "<tr bgcolor='#64AAD0'>";
  foreach($attributes as $val){	
    echo "<td>".$val->name."</td>";	
  }
  echo "</tr>";

while ($row = mysqli_fetch_row($QueryResult)) {
  echo "<tr>";
  for($i=0; $i<$num_attributes;$i++){
	
	echo "<td>".$row[$i]."</td>";	

	}

  echo "<td><a href='form.php?test_series=".$row[1]."'>[Add test]</a></td>";
  echo "<td><a href='battery_statistics.php?test_series=".$row[1]."'>[View battery statistics]</a></td>";
  echo "<td><a href='lock_statistics.php?test_series=".$row[1]."'>[View lock statistics]</a></td>";
  echo "</tr>";
}

echo "</table>";

?>



<html>
<body>

</body>
</html>
